using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Entities;
using Bll;

public partial class ForgotPassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lblCheckuser.Visible = false;
            lblPassword.Visible = false;
            btnValidate.Visible = false;
            lblQuestion.Visible = false;
            txtAnswer.Visible = false;
        }
    }
    protected void btnCheck_Click(object sender, EventArgs e)
    {
        AccountBll accBll = new AccountBll();

        if (accBll.CheckExistAccount(txtUsername.Text))
        {
            lblCheckuser.Text = "Username is correct";
            lblQuestion.Text = accBll.GetQuestion(txtUsername.Text);
            lblQuestion.Visible = true;
            txtAnswer.Visible = true;
            btnValidate.Visible = true;
            lblCheckuser.Visible = true;
        }
        else
        {
            lblCheckuser.Text = "Username incorrect";
            lblPassword.Visible = false;
            btnValidate.Visible = false;
            lblQuestion.Visible = false;
            txtAnswer.Visible = false;
            lblCheckuser.Visible = true;
        }
    }
    protected void btnValidate_Click(object sender, EventArgs e)
    {

        AccountBll accBll = new AccountBll();

        if (!string.IsNullOrEmpty(accBll.CheckAnswer(txtAnswer.Text)))
        {
            lblPassword.Text = "Your Password is :" + accBll.CheckAnswer(txtAnswer.Text);
            lblPassword.Visible = true;
        }
        else
        {
            lblPassword.Text = "Your answer incorrect ! Please try again";
            lblPassword.Visible = true;
        }

    }
}
